home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / fontutil.6 / fontutil / fontutils-0.6 / include / gf.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-13  |  5.3 KB  |  156 lines

  1. /* gf.h: manipulate generic font files.  See Metafont: The Program, by
  2.    Don Knuth, (Volume D of Computers & Typesetting), chapter 46, among
  3.    other places, for the precise definition of this bitmap format.
  4.  
  5. Copyright (C) 1992 Free Software Foundation, Inc.
  6.  
  7. This program is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2, or (at your option)
  10. any later version.
  11.  
  12. This program is distributed in the hope that it will be useful,
  13. but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. GNU General Public License for more details.
  16.  
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
  20.  
  21. #ifndef GENERIC_FONT_LIBRARY_H
  22. #define GENERIC_FONT_LIBRARY_H
  23.  
  24. #include "bitmap.h"
  25. #include "bounding-box.h"
  26. #include "font.h"
  27. #include "types.h"
  28.  
  29.  
  30. /* At most one GF file can be open for reading (or writing) at a time.
  31.    You must call `gf_open_input_file' before using any of the `gf_get...'
  32.    routines; similarly for the output side.  */
  33.  
  34. extern boolean gf_open_input_file (string filename);
  35. extern void gf_close_input_file (void);
  36.  
  37. extern boolean gf_open_output_file (string filename);
  38. extern void gf_close_output_file (void);
  39.  
  40. /* The only interesting information in the preamble is the comment.  */
  41.  
  42. extern string gf_get_preamble (void);
  43. extern void gf_put_preamble (string comment);
  44.  
  45.  
  46. /* An important part of the postamble is the character locators.  A
  47.    character exists in the GF file if its `char_pointer' member in this
  48.    structure is not `NULL_BYTE_PTR'.  */
  49. typedef struct
  50. {
  51.   charcode_type charcode;
  52.   signed_4_bytes h_escapement;
  53.   fix_word tfm_width;
  54.   signed_4_bytes char_pointer;
  55. } gf_char_locator_type;
  56.  
  57.  
  58. typedef struct
  59. {
  60.   fix_word design_size;
  61.   unsigned checksum;
  62.   real h_resolution, v_resolution;
  63.   bounding_box_type font_bb;
  64.   gf_char_locator_type char_loc[MAX_CHARCODE + 1];
  65. } gf_postamble_type;
  66.  
  67. /* The design size is given as a fix_word in TeX points.  */
  68. #define GF_DESIGN_SIZE(p)  ((p).design_size)
  69.  
  70. /* The GF checksum should match the checksums in the TFM file and/or the
  71.    PK file, if they exist.  */
  72. #define GF_CHECKSUM(p)  ((p).checksum)
  73.  
  74. /* We express the resolutions in pixels per point multiplied by 2^16.  */
  75. #define GF_H_RESOLUTION(p)  ((p).h_resolution)
  76. #define GF_V_RESOLUTION(p)  ((p).v_resolution)
  77.  
  78. /* The font bounding box may not be the tightest possible.  */
  79. #define GF_FONT_BB(p)  ((p).font_bb)
  80.  
  81. /* An abbreviation for a particular character locator.  */
  82. #define GF_CHAR_LOC(p, code)  ((p).char_loc[code])
  83.  
  84.  
  85. /* Return the postamble in the input file.  */
  86. extern gf_postamble_type gf_get_postamble (void);
  87.  
  88. /* Write the postamble to the output file.  The library fills in the
  89.    information that is not given as arguments.  This must be called
  90.    after all the characters have been written.  The resolution arguments
  91.    should be given in pixels per inch.  */
  92. extern void gf_put_postamble (fix_word design_size,
  93.                               real h_resolution, real v_resolution);
  94.  
  95. /* The characters are the most important information in the GF file.  */
  96.  
  97. typedef struct
  98. {
  99.   charcode_type code;
  100.   bitmap_type bitmap;
  101.   bounding_box_type bb;
  102.   signed_4_bytes h_escapement;
  103.   fix_word tfm_width;
  104. } gf_char_type;
  105.  
  106. /* GF format actually allows character codes to be a full four bytes
  107.    long, but we cannot deal with such fonts.  */
  108. #define GF_CHARCODE(gc)  ((gc).code)
  109.  
  110. /* The pixels.  See `bitmap.h'.  */
  111. #define GF_BITMAP(gc)  ((gc).bitmap)
  112.  
  113. /* GF format does not guarantee that the bounding box is the tightest
  114.    possible, but the reading routines do.  */
  115. #define GF_CHAR_BB(gc)  ((gc).bb)
  116.  
  117. /* The set width, in pixels.  */
  118. #define GF_H_ESCAPEMENT(gc)  ((gc).h_escapement)
  119.  
  120. /* The character width as a fix_word.  */
  121. #define GF_TFM_WIDTH(gc) ((gc).tfm_width)
  122.  
  123. /* Conveniently access each member of the bounding box.  */
  124. #define GF_CHAR_MIN_COL(gc)  (MIN_COL (GF_CHAR_BB (gc)))
  125. #define GF_CHAR_MAX_COL(gc)  (MAX_COL (GF_CHAR_BB (gc)))
  126. #define GF_CHAR_MIN_ROW(gc)  (MIN_ROW (GF_CHAR_BB (gc)))
  127. #define GF_CHAR_MAX_ROW(gc)  (MAX_ROW (GF_CHAR_BB (gc)))
  128.  
  129. /* An abbreviation for the left side bearing ...  */
  130. #define GF_CHAR_LSB  GF_CHAR_MIN_COL
  131.  
  132. /* ... and one for the right side bearing.  */
  133. #define GF_CHAR_RSB(c) (GF_H_ESCAPEMENT (c) - GF_CHAR_MAX_COL (c))
  134.  
  135.  
  136. /* `gf_get_next_char' reads the next character from the input file and returns
  137.    it.  It also returns (as an argument) whether a character was
  138.    actually found.  If not, you've read to the postamble.  */
  139. extern gf_char_type gf_get_next_char (boolean *found);
  140.  
  141. /* `gf_get_char' returns a pointer to the character numbered CODE
  142.    in the input file, or a null pointer if that character doesn't exist.  */ 
  143. extern gf_char_type *gf_get_char (charcode_type code);
  144.  
  145. /* Read the character CODE but don't interpret it; the result is only
  146.    useful as a parameter to `gf_put_raw_char'.  */
  147. extern raw_char_type *gf_get_raw_char (charcode_type code);
  148.  
  149. /* Write the given character to the output file.  */
  150. extern void gf_put_char (gf_char_type);
  151.  
  152. /* Write the given raw character.  */
  153. extern void gf_put_raw_char (raw_char_type);
  154.  
  155. #endif /* not GENERIC_FONT_LIBRARY_H */
  156.